<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Book_model extends CI_Model
{
    function __construct()
    {
        parent::__construct();
        /*
         * working with database
         */
        $this->load->database();
    }

    function fetch_all_book($limit, $start)
    {
        $this->db->select('*');
        $this->db->from('booklist');
        $this->db->limit($limit, $start);
        $query = $this->db->get();

        if($query->num_rows() > 0)
        {
            $data = array();
            foreach($query->result() as $book) // fetch object
            {
                $data[] = $book;
            }
            return $data;
        }
        return false;
    }

    function rows_count()
    {
        $this->db->select('*');
        $this->db->from('booklist');
        $query = $this->db->get();

        return $query->num_rows();
    }
}

